using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Build.Framework;
using Microsoft.EnterpriseSingleSignOn.Interop;

namespace BizTalk.BuildGenerator.Tasks.SSO
{
    /// <summary>
    /// Populates a custom property in an SSO application with data
    /// </summary>
    public class PopulateApplicationProperty : BaseSSOTask 
    {
        private string _ApplicationName;
        private string _Data;
        private string _PropertyName;
        
        /// <summary>
        /// The name of the application property
        /// </summary>
        [Required]
        public string PropertyName
        {
            get { return _PropertyName; }
            set { _PropertyName = value; }
        }
        /// <summary>
        /// The data to populate in the field
        /// </summary>
        [Required]
        public string Data
        {
            get { return _Data; }
            set { _Data = value; }
        }
        /// <summary>
        /// Name of the sso application
        /// </summary>
        [Required]
        public string ApplicationName
        {
            get { return _ApplicationName; }
            set { _ApplicationName = value; }
        }
        /// <summary>
        /// Executes the task
        /// </summary>
        /// <returns></returns>
        public override bool Execute()
        {
            Console.WriteLine("Executing Populate Application Property");
            
            SSOConfiguration.Write(this._ApplicationName, this._PropertyName, this._Data);
            return true;
        }
    }
}
